<?php
    require_once '../Tool/Common/PrepareInput.php';

    session_start();
    if (empty($_SESSION["userType"])) {
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }

    if($_SESSION["userType"]!="System Admin"){
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }
    
    $HolidayName=$UpdateDate=$ID="";  

    if(isset($_REQUEST['HolidayName'])){ 
        $HolidayName=prepareInput($_REQUEST['HolidayName']); 
    }
    if(isset($_REQUEST['UpdateDate'])){ 
        $UpdateDate=prepareInput($_REQUEST['UpdateDate']); 
    }
    if(isset($_REQUEST['ID'])) { 
        $ID=prepareInput($_REQUEST['ID']); 
    }

    $result=array();

    $result['flagHolidayName']=0;
    $result['flagUpdateDate']=0;
    $result['flagID']=0;  

    if(preg_match("/^[A-Za-z0-9()'' ]*$/",$HolidayName)&&!empty($HolidayName)){
        $result['flagHolidayName']=1;
    }
    if(!empty($UpdateDate)&&preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$UpdateDate)){
        $result['flagUpdateDate']=1;
    }
    if(preg_match("/^[0-9]*$/",$ID)&&!empty($ID)){
        $result['flagID']=1;
    }

    echo json_encode($result);
?>